package bufferReader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class test_read {
    public static void main(String[] args) throws IOException {
        allRead();
    }

    private static void allRead() throws IOException {
        FileReader fileReader=new FileReader("D:\\java\\JavaMaterial\\1.txt");
        //字符数组
        char[]chars=new char[1024];
        int len;
        while ((len=fileReader.read(chars))!=-1){
           String s=new String(chars,0,len);
            System.out.println(s);
        }
        fileReader.close();
    }

    private static void singleRead() throws IOException {
        FileReader fileReader=new FileReader("D:\\java\\JavaMaterial\\1.txt");
        int len;
        while ((len=fileReader.read())!=-1){
            System.out.println((char)len);
        }
        fileReader.close();
    }
}
